package com.chhuang.utils.httpRequest;

import java.util.LinkedList;
import java.util.List;
import java.util.Locale;

import org.apache.commons.lang.StringUtils;
import org.apache.http.Header;
import org.apache.http.ProtocolVersion;
import org.apache.http.StatusLine;

/**
 * 在HttpClientUtil中使用
 * responseBean
 * 
 * @author PrinceChen
 *
 */
public class ResponseBean {
	private Header[] headers;
	private Locale locale;
	private ProtocolVersion protocolVersion;
	private StatusLine statusLine;
	private String result;
	
	
	public ResponseBean() {
		super();
	}
	public ResponseBean(Header[] headers, Locale locale,
			ProtocolVersion protocolVersion, StatusLine statusLine,
			String result) {
		super();
		this.headers = headers;
		this.locale = locale;
		this.protocolVersion = protocolVersion;
		this.statusLine = statusLine;
		this.result = result;
	}

	public Header[] getHeaders() {
		return headers;
	}
	public Header[] getHeaders(String name) {
		Header[] nameHeaders = null;
		if(StringUtils.isNotBlank(name) && headers!=null && headers.length>0){
			List<Header> nameHeaderList = new LinkedList<Header>();
			for(Header header : headers){
				if(name.equalsIgnoreCase(header.getName())){
					nameHeaderList.add(header);
				}
			}
			nameHeaders = (Header[]) nameHeaderList.toArray(new Header[nameHeaderList.size()]);
		}
		return nameHeaders;
	}
	public void setHeaders(Header[] headers) {
		this.headers = headers;
	}
	public Locale getLocale() {
		return locale;
	}
	public void setLocale(Locale locale) {
		this.locale = locale;
	}
	public ProtocolVersion getProtocolVersion() {
		return protocolVersion;
	}
	public void setProtocolVersion(ProtocolVersion protocolVersion) {
		this.protocolVersion = protocolVersion;
	}
	public StatusLine getStatusLine() {
		return statusLine;
	}
	public void setStatusLine(StatusLine statusLine) {
		this.statusLine = statusLine;
	}
	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}
}
